Repository navigation
Fix get_history_metadata() raising YFPricesMissingError for valid tickers (#2745) - #2795
Open
Jaypatel1511 wants to merge 2 commits into
Open
Jaypatel1511 wants to merge 2 commits into
Jaypatel1511 wants to merge 2 commits into
Conversation
Contributor
|
Also this if statement does do what you said, but the way it is written it reads like you are checking if either meta or history_metadata is None, something a little more explicit might be nice. if meta or self._history_metadata is None:
self._history_metadata = meta |
Collaborator
@etbala TBF codebase is already littered with similar statements, mostly in |
Collaborator
…kers (ranaroussi#2745) Two bugs in scrapers/history.py: 1. history() always overwrote _history_metadata with {} on a failed fetch, destroying previously cached good metadata from a prior successful call. Fix: only update _history_metadata when the new meta is non-empty or when it has never been set. 2. get_history_metadata() let YFPricesMissingError from the optional intraday tradingPeriods enrichment call propagate to the caller, even when currency, exchangeName, timezone, etc. were already cached. Fix: catch YFPricesMissingError around the enrichment call and return whatever metadata is already available.
`call` and `patch` were imported but never referenced in the test file, causing the Ruff F401 check to fail in CI.
Jaypatel1511
force-pushed
the
fix/get-history-metadata-missing-error
branch
from
May 5, 2026 21:59
acbd782 to
e500447
Compare
Contributor
Author
|
Rebased onto dev. |
Contributor
@Jaypatel1511 Just in case it wasn't clear, this is still an issue. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2745 —
get_history_metadata()raisedYFPricesMissingErrorfor valid, non-delisted tickers (e.g.ROG.SW) even afterhistory()succeeded, because the optional intraday enrichment call failed and was not caught.Two bugs fixed in
scrapers/history.py:Bug 1 — good metadata overwritten by failed fetch (line ~240)
history()unconditionally wroteself._history_metadata = metaafter every fetch. When the intraday enrichment request returned no data,metawas{}, silently destroying thecurrency,exchangeName,timezone, etc. already cached from a prior successfulhistory()call.Fix: only overwrite
_history_metadatawhen the new meta is non-empty, or when it has never been set:Bug 2 — YFPricesMissingError propagates from optional enrichment call
get_history_metadata()called_get_history_cache(period="5d", interval="1h")to populatetradingPeriods. For some tickers/exchanges (e.g. Swiss exchange), intraday data is unavailable and this raisedYFPricesMissingError, even though all core metadata was already cached.Fix: catch
YFPricesMissingErroraround the enrichment call and return whatever metadata is already available:Test plan
tests/test_get_history_metadata.pywith 4 regression casesget_history_metadata()returns cached metadata instead of raising